﻿// =================================================================== 
// 模块说明
//====================================================================
// 创建时间：2018-05-15 10:35:53
// 负责人：Sushee
// ===================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq.Expressions;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using System.Text;
namespace OF.Component.DAL
{
	
	/// <summary>
	/// 数据访问层
	/// </summary>	
	internal partial class AuthoritySystem
	{		
    
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public AuthoritySystemInfo QuerySingle(Expression<Func<AuthoritySystemInfo, bool>> predicate)
	    {
            return SQLServerProvider.CreateObject(ConnectionStringKey, predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
	    public IList<AuthoritySystemInfo> QueryList(Expression<Func<AuthoritySystemInfo, bool>> predicate)
	    {
	        return SQLServerProvider.CreateList(ConnectionStringKey, predicate);
	    }
        public DataTable GetUserSystem(int UseID)
        {
            Database db = DatabaseFactory.CreateDatabase(this.ConnectionStringKey);
            DbCommand dbc = db.GetSqlStringCommand(@"SELECT a.SystemID,a.SystemName,b.systemid usersystemid
                                                      FROM [dbo].[AuthoritySystem] a LEFT JOIN
                                                      dbo.AuthorityUserSystemRela b ON a.SystemID=b.SystemID AND b.UseID=@UseID
                                                      WHERE a.[IsActive]=1  ");
            //设置参数
            db.AddInParameter(dbc, "@UseID", DbType.Int32, UseID);

            DataTable list = db.ExecuteDataSet(dbc).Tables[0];

            return list;
        }
    }
	
}